package com.sjm.learn.lock;

/**
 * @Description:案例1
 * @Author：shenjm25081
 * @Date：11:38 2019-2-21
 */
public class SynchronizedDemo1 implements Runnable{

    private static int count = 0;

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            Thread thread = new Thread(new SynchronizedDemo1());
            thread.start();
        }
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("result: " + count);
    }


    @Override
    public void run() {
        for (int i = 0; i < 1000000; i++){
            count++;
        }
    }
}
